package com.car.web.controller.index;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.car.dal.dao.department.TgDepartmentDao;
import com.car.dal.dao.office.TgOfficeDao;
import com.car.dal.dao.quit.QuitDao;
import com.car.dal.dao.recruitment.GoodProvideDao;
import com.car.dal.dao.recruitment.RecruitmentDao;
import com.car.dal.dao.recruitment.RecruitmentPeopleDao;
import com.car.dal.dao.recruitment.RecruitmentResultDao;
import com.car.dal.dao.storage.StorageDao;
import com.car.dal.dao.survey.SatisSurveyDao;
import com.car.dal.dao.user.UserDao;
import com.car.dal.dao.user.UserinfoDao;
import com.car.dal.object.RecruitmentRate;
import com.car.dal.object.TgDepartment;
import com.car.dal.object.TgGoodProvide;
import com.car.dal.object.TgOffice;
import com.car.dal.object.TgQuit;
import com.car.dal.object.TgRecruitment;
import com.car.dal.object.TgRecruitmentPeople;
import com.car.dal.object.TgRecruitmentResult;
import com.car.dal.object.TgSatisSurvey;
import com.car.dal.object.TgStorage;
import com.car.dal.object.TgUser;
import com.car.dal.object.TgUserinfo;
import com.car.dal.object.YgZl;
import com.car.exception.BaseException;
import com.car.util.DateUtil;
import com.car.util.JsonExecutor;
import com.car.util.Page;
import com.car.util.PageUtil;
import com.car.util.Result;
import com.car.util.ResultSupport;
import com.car.util.UserUtil;
import com.car.util.WebExecutor;
import com.car.util.JsonExecutor.JsonBiz;
import com.car.util.WebExecutor.Biz;
import com.car.util.WriterExcel;
import com.car.web.controller.base.BaseController;
import com.car.web.controller.base.BaseVo;


/**
 * 招聘信息
 * @author d
 *
 */
@Controller
@RequestMapping("/recruitment")
public class RecruitmentController extends BaseController{
	 private static final Logger logger = Logger.getLogger(SystemController.class);  
	 private static DecimalFormat df = new DecimalFormat("#.00"); 
	 private static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	 @Resource
	 private RecruitmentDao recruitmentDao;
	 @Resource
	 private TgOfficeDao tgOfficeDao;
	 @Resource
	 private RecruitmentResultDao recruitmentResultDao;
	 @Resource
	 private RecruitmentPeopleDao recruitmentPeopleDao;
	 @Resource
	 private UserDao userDao;
	 @Resource
	 private SatisSurveyDao satisSurveyDao;
	 @Resource
	 private QuitDao  quitDao;
	 @Resource
	 private UserinfoDao userinfoDao;
	 @Resource
	 private GoodProvideDao  goodProvideDao;
	 @Resource
	 private StorageDao  storageDao;
	 @Resource
	 private TgDepartmentDao tgDepartmentDao;
	 /**
	  * 电话邀约列表
	  * @param modelMap
	  * @param vo
	  * @param request
	  * @param response
	  * @return
	  * @throws Exception
	  */
	 @RequestMapping(value = "/recruitment_list")
	 public ModelAndView recruitment_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                TgRecruitment tgRecruitment=new TgRecruitment();
	                String dateday=request.getParameter("dateday");
	                String datemoth=request.getParameter("datemoth"); 
	                String name=request.getParameter("name");
	                TgUser user=UserUtil.getCookieUser();
	                if(!user.getUsername().equals("system")){
	                	if(user.getType()!=null&&(user.getType()==3||user.getType()==1)) {
	                		tgRecruitment.setCenter(user.getRegion());
	                	}else{
	                		tgRecruitment.setLogin_name(user.getUsername());
	                	}
	                	
	                }
	                if(dateday!=null&&!"".equals(dateday)){
	                	if(dateday.contains("-")){
	                		dateday=dateDay(dateday);
	                	}
	                	
	                	tgRecruitment.setDateday(dateday);
	                }
	                if(datemoth!=null&&!"".equals(datemoth)){
	                   if(datemoth.contains("-")){
	                	   datemoth=dateMoth(datemoth);
	                   }
	            	   tgRecruitment.setDatemoth(datemoth);
	                }
	                if(name!=null&&!"".equals(name)){
	                	tgRecruitment.setName(name);
	                }
	              
	                Integer currPage = vo.getCurrPage() == null ? 1 : vo.getCurrPage();
	                if((dateday!=null&&!"".equals(dateday))||(datemoth!=null&&!"".equals(datemoth))){
	                	Integer total=recruitmentDao.getTgCountRecruitmentByType1(tgRecruitment);
	                	Page page=PageUtil.createPage(10, currPage, total);
	   	                List<TgRecruitment>list=recruitmentDao.getTgRecruitmentByType4(tgRecruitment, page);
	   	                result.setDefaultModel("list", list);
		                result.setDefaultModel("page", page);
	                }else{
	                	Integer total=recruitmentDao.getTgCountRecruitmentByType(tgRecruitment);
	  	                Page page=PageUtil.createPage(10, currPage, total);
	  	                List<TgRecruitment>list=recruitmentDao.getTgRecruitmentByType(tgRecruitment, page);
	  	                result.setDefaultModel("list", list);
		                result.setDefaultModel("page", page);
	                }
	              
	                result.setDefaultModel("dateday", dateday);
	                result.setDefaultModel("datemoth", datemoth);
	                result.setDefaultModel("name", name);
	              
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/recruitment_list", modelMap);
	    }
	    @RequestMapping(value = "/add_recruitment")
	   	public ModelAndView add_recruitment(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	   		modelMap = WebExecutor.execute(logger, vo, new Biz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				String id=request.getParameter("id"); 
	   				if(id!=null&&!"".equals(id)){
	   					TgRecruitment recruitment=recruitmentDao.findById(TgRecruitment.class, Long.parseLong(id));
	   					result.setDefaultModel("recruitment", recruitment);
	   				}
	   			    List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);//查询中心
				    result.setDefaultModel("office_List", office_List);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_recruitment", modelMap);
	   }
	    /**
	     * 添加预约人员
	     * @param modelMap
	     * @param vo
	     * @param request
	     * @param response
	     * @return
	     * @throws Exception
	     */
	    @RequestMapping(value = "/addRecruitment")
	   	public ModelAndView addRecruitment(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				try {
	   					String id = request.getParameter("id");
	   				    String name = request.getParameter("name");
	   				    String center=request.getParameter("center");
	   				    String sex = request.getParameter("sex");
	   				    String phone = request.getParameter("phone");
	   				    String education = request.getParameter("education");
	   				    String major = request.getParameter("major");
	   				    String university = request.getParameter("university");
		   			    String post = request.getParameter("post");
		   				String source = request.getParameter("source");
		   				String type = request.getParameter("type");
		   				String success = request.getParameter("success");
		   				String invitations = request.getParameter("invitations");
		   				String dateofinvitation = request.getParameter("dateofinvitation");
		   				String time = request.getParameter("time");
		   				TgUser user=UserUtil.getCookieUser();
		   				TgRecruitment recruitment=new TgRecruitment();
		   				recruitment.setUsername(user.getNickname());
		   				recruitment.setLogin_name(user.getUsername());
		   				recruitment.setName(name);
		   				if(sex!=null&&!"".equals(sex)){
		   					recruitment.setSex(Integer.parseInt(sex));
		   				}
		   				if(center!=null&&!"".equals(center)){
		   					recruitment.setRegion(center.substring(0,2));
		   					recruitment.setCenter(center);
		   					recruitment.setAddress(center.substring(0,center.length()-2));
		   				}
		   				recruitment.setPhone(phone);
		   				recruitment.setEducation(education);
		   				recruitment.setMajor(major);
		   				recruitment.setUniversity(university);
		   				recruitment.setPost(post);
		   				recruitment.setSource(source);
		   				recruitment.setInvitations(invitations);
		   				recruitment.setTime(time);
		   				if(type!=null&&!"".equals(type)){
		   					recruitment.setType(Integer.parseInt(type));
		   				}
		   				if(success!=null&&!"".equals(success)){
		   					recruitment.setSuccess(Integer.parseInt(success));
		   				}
		   				if(dateofinvitation!=null&&!"".equals(dateofinvitation)){
		   					SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
			   				Date d=sdf.parse(dateofinvitation);
							recruitment.setDateofinvitation(d);
		   				}
		   				recruitment.setCreate_time(new Date());
						if(id!=null&&!"".equals(id)){
							recruitment.setId(Long.parseLong(id));
							recruitmentDao.update(recruitment);
	   				    }else{
	   				    	recruitmentDao.insert(recruitment);
	   				    }
						result.setDefaultModel("msg", "1");
	   				}catch (ParseException e) {
						e.printStackTrace();
					}
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_recruitment", modelMap);
	   	}
	    /**
	     * 面试结果列表
	     * @param modelMap
	     * @param vo
	     * @param request
	     * @param response
	     * @return
	     * @throws Exception
	     */
	    @RequestMapping(value = "/recruitment_result_list")
	    public ModelAndView recruitment_result_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                TgRecruitmentResult tgRecruitmentResult=new TgRecruitmentResult();
					TgUser user=UserUtil.getCookieUser();
					if(!user.getUsername().equals("system")){
						tgRecruitmentResult.setLogin_name(user.getUsername());
					}
				
	                String dateday=request.getParameter("dateday");
	                String datemoth=request.getParameter("datemoth"); 
	                String week=request.getParameter("week");
	                if(dateday!=null&&!"".equals(dateday)){
	                	dateday=dateDay(dateday);
	                	tgRecruitmentResult.setDateday(dateday);
	                }
	                if(datemoth!=null&&!"".equals(datemoth)){
	            	   datemoth= dateMoth(datemoth);
	            	   tgRecruitmentResult.setDatemoth(datemoth);
	                }
	                if(week!=null&&!"".equals(week)){
	                	List<String>list=DateUtil.printWeekdays(week);
	                	if(list!=null&&list.size()>0){
	                		tgRecruitmentResult.setStart(list.get(0));
	                		tgRecruitmentResult.setEnd(list.get(6));
	                	}
	                }
	             
	                Integer currPage = vo.getCurrPage() == null ? 1 : vo.getCurrPage();
	                Integer total=recruitmentResultDao.getTgCountRecruitResultByType(tgRecruitmentResult);
	                Page page=PageUtil.createPage(10, currPage, total);
	                List<TgRecruitmentResult>list=recruitmentResultDao.getTgRecruitResultByType(tgRecruitmentResult, page);
	                result.setDefaultModel("list", list);
	                result.setDefaultModel("page", page);
	                
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/recruitment_result_list", modelMap);
	    }
	    //补填面试结果
	    @RequestMapping(value = "/add_recruitment_result")
	   	public ModelAndView add_recruitment_result(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	   		modelMap = WebExecutor.execute(logger, vo, new Biz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				String id=request.getParameter("id"); 
	   				TgUser user=UserUtil.getCookieUser();
	   				TgRecruitment tgRecruitment=new TgRecruitment();
	   				String type=request.getParameter("type");
	   				if(!user.getUsername().equals("system")){
	   					if(user.getType()!=null&&(user.getType()==1||user.getType()==3)){
	   						tgRecruitment.setCenter(user.getRegion());
	   					}else{
	   						tgRecruitment.setLogin_name(user.getUsername());
	   					}
	   				}
	   				if(id!=null&&!"".equals(id)){
	   					TgRecruitmentResult tgRecruitmentResult=recruitmentResultDao.findById(TgRecruitmentResult.class, Long.parseLong(id));
	   					if(tgRecruitmentResult.getRecruitment_id()!=null){
	   						TgRecruitment Recruitment=recruitmentDao.findById(TgRecruitment.class, tgRecruitmentResult.getRecruitment_id());
	   						tgRecruitmentResult.setName(Recruitment.getName());
	   						 
	   					}
	   					result.setDefaultModel("tgRecruitmentResult", tgRecruitmentResult);
	   				}
	   				if(type==null||"".equals(type)){
	   					Date d=new Date();
		   				SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
		   				String dateday= sdf.format(d);
		   				tgRecruitment.setDateday(dateday);
	   				}
	   				
	   			    List<TgRecruitment> list =recruitmentDao.getTgRecruitmentByType1(tgRecruitment);//面试邀请，要今天面试的人
				    result.setDefaultModel("list", list);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_recruitment_result", modelMap);
	   }
	    
	    //模糊查找来面试的人员
	    @RequestMapping(value = "/getUserByNickname")
	    public ModelAndView getUserBynickname(ModelMap modelMap,
	  			final BaseVo vo, final HttpServletRequest request,
	  			final HttpServletResponse response) throws Exception {
	  		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	  			public Result process() {
	  				Result result = new ResultSupport(true);
	  				String nickname = request.getParameter("nickname");
	  				TgUser user=UserUtil.getCookieUser();
	  				TgRecruitment tgRecruitment=new TgRecruitment();
	  				tgRecruitment.setName(nickname);
	  				tgRecruitment.setLogin_name(user.getUsername());
	     			List<TgRecruitment> list =recruitmentDao.getTgRecruitmentByType1(tgRecruitment);
	     			if(list!=null && list.size()>0){
	     				result.setDefaultModel("list", list.get(0));
	     			}
	  				return result;
	  			}
	  		});
	  		return new ModelAndView("", modelMap);
	  	}
	    
	    /**
	     * 添加面试结果
	     * @param modelMap
	     * @param vo
	     * @param request
	     * @param response
	     * @return
	     * @throws Exception
	     */
	    @RequestMapping(value = "/addrecruitmentresult")
	   	public ModelAndView addrecruitmentresult(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   			    String id = request.getParameter("id");
	   			    String recruitment_id=request.getParameter("recruitment_id");
	   				String rt = request.getParameter("result");
	   				String detail = request.getParameter("detail");
	   				String time=request.getParameter("time");
	   				String beizhu = request.getParameter("beizhu");	
	   				List<TgRecruitmentResult>li=null;
	   				TgRecruitmentResult tgRecruitmentResult=new TgRecruitmentResult();
	   				tgRecruitmentResult.setDetails(detail);
	   				tgRecruitmentResult.setBeizhu(beizhu);
	   				if(rt!=null&&!"".equals(rt)){
	   					tgRecruitmentResult.setResult(Integer.parseInt(rt));
	   				}
	   				if(recruitment_id!=null&&!"".equals(recruitment_id)){
	   					tgRecruitmentResult.setRecruitment_id(Long.parseLong(recruitment_id));
	   					Page page=PageUtil.createPage(10, 1, 10);
	   				    li=recruitmentResultDao.getTgRecruitResultByType(tgRecruitmentResult, page);
				    }
	   				if(id!=null&&!"".equals(id)){
	   					tgRecruitmentResult.setId(Long.parseLong(id));
	   					recruitmentResultDao.update(tgRecruitmentResult);
	   					result.setDefaultModel("msg", "1");
	   				}else{
	   					if(li!=null&&li.size()>0){
		   					result.setDefaultModel("msg", "2");//已经添加过了，不能重复添加
		   				}else{
		   					if(time!=null&&!"".equals(time)){//补填的时候
		   						try {
									Date d=sdf.parse(time);
									tgRecruitmentResult.setCreate_time(d);
								} catch (ParseException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
		   					}else{
		   						tgRecruitmentResult.setCreate_time(new Date());
		   					}
			   				
			   				recruitmentResultDao.insert(tgRecruitmentResult);
			   				result.setDefaultModel("msg", "1");
		   				}
	   				}
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_recruitment_result", modelMap);
	   	}
	    /**
	     * 入职情况列表
	     */
	    @RequestMapping(value = "/recruitment_people_list")
	    public ModelAndView recruitment_people_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	               
	                String datemoth=request.getParameter("datemoth");
	                String type=request.getParameter("type");
	                TgRecruitmentPeople tgRecruitmentPeople=new TgRecruitmentPeople();
            		
	                TgUser user=UserUtil.getCookieUser();
	                if(!user.getUsername().equals("system") && !user.getUsername().equals("yuanjing")&& !user.getUsername().equals("yexiling")){
	                	tgRecruitmentPeople.setLogin_name(user.getUsername());
	                }
	                if(datemoth!=null&&!"".equals(datemoth)){
            			tgRecruitmentPeople.setDatemoth(datemoth);
            		}
	                if(type!=null&&!"".equals(type)){
	                	tgRecruitmentPeople.setType(Integer.parseInt(type));
	                }
	                Integer currPage = vo.getCurrPage() == null ? 1 : vo.getCurrPage();
	                Integer total=recruitmentPeopleDao.getTgCountRecruitPeopleByType(tgRecruitmentPeople);
	                Page page=PageUtil.createPage(10, currPage, total);
	                List<TgRecruitmentPeople>list=recruitmentPeopleDao.getTgRecruitPeopleByType(tgRecruitmentPeople, page);
	                result.setDefaultModel("list", list);
	                result.setDefaultModel("page", page);
	                result.setDefaultModel("type", type);
	                result.setDefaultModel("datemoth", datemoth);
	                result.setDefaultModel("usern", user.getUsername());
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/recruitment_people_list", modelMap);
	    }
	    //添加员工情况表
	    @RequestMapping(value = "/add_recruitment_people")
	   	public ModelAndView add_recruitment_people(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	   		modelMap = WebExecutor.execute(logger, vo, new Biz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				String id=request.getParameter("id"); 
	   				String type=request.getParameter("type");
	   				TgUser user=UserUtil.getCookieUser();
	   				if(id!=null&&!"".equals(id)){
	   				    TgRecruitmentPeople tgRecruitmentPeople=recruitmentPeopleDao.findById(TgRecruitmentPeople.class, Long.parseLong(id));
	   					TgRecruitmentResult tgRecruitmentResult=recruitmentResultDao.findById(TgRecruitmentResult.class, tgRecruitmentPeople.getRecruitment_result_id());
	   					TgRecruitment recruitment=recruitmentDao.findById(TgRecruitment.class, tgRecruitmentResult.getRecruitment_id());
	   					tgRecruitmentPeople.setName(recruitment.getName());
	   					tgRecruitmentPeople.setRecruitment_result_id(tgRecruitmentResult.getId());
	   					result.setDefaultModel("tgRecruitmentPeople", tgRecruitmentPeople);
	   				}
	   				TgRecruitmentPeople tgRecruitmentPeople=new TgRecruitmentPeople();
	   				tgRecruitmentPeople.setLogin_name(user.getUsername());
	   				if(type!=null&&!"".equals(type)){
	   				    List<TgRecruitmentPeople> list =recruitmentPeopleDao.getTgRecruitPeopleByType1(tgRecruitmentPeople);//本月成功通过面试的人
					    result.setDefaultModel("list", list);
	   				}else{
	   					Date d=new Date();
		   				SimpleDateFormat sdf=new SimpleDateFormat("yyyyMM");
		   				String datemoth= sdf.format(d);
		   				tgRecruitmentPeople.setDatemoth(datemoth);
		   			    List<TgRecruitmentPeople> list =recruitmentPeopleDao.getTgRecruitPeopleByType1(tgRecruitmentPeople);//本月成功通过面试的人
					    result.setDefaultModel("list", list);
	   				}
	   				result.setDefaultModel("usern", user.getUsername());
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_recruitment_people", modelMap);
	   }
	    //下载员工情况表
	    @RequestMapping(value = "/download_recruitment")
	   	public ModelAndView download_recruitment(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				String math=request.getParameter("datemoth");

	   				TgRecruitmentPeople tgRecruitment=new TgRecruitmentPeople();
	   				if(math!=null&&!"".equals(math)){
	   					tgRecruitment.setDatemoth(math);
	                }
	   				List<TgRecruitmentPeople>recruitment=recruitmentPeopleDao.getSatisrecruitment(tgRecruitment);
	                String name= WriterExcel.writerecruitment(recruitment);
	                result.setDefaultModel("name", name);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("", modelMap);
	   	}
	    
	    @RequestMapping(value = "/addrecruitmentpeople")
	   	public ModelAndView addrecruitmentpeople(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				try {
	   			        String id = request.getParameter("id");
	   			        String type=request.getParameter("type");
	   			        String incomecompanytime=request.getParameter("incomecompanytime");
	   			        String recruitment_result_id = request.getParameter("recruitment_result_id");
		   				String employeeperiod = request.getParameter("employeeperiod");
		   				String probationperiod = request.getParameter("probationperiod");	
		   				String transactionsituation=request.getParameter("transactionsituation");
		   				String boccardnumber=request.getParameter("boccardnumber");
		   			    TgRecruitmentPeople tgRecruitmentPeople=new TgRecruitmentPeople();
		   			    List<TgRecruitmentPeople>list=null;
		   			    TgRecruitmentResult tgRecruitmentResult=new TgRecruitmentResult();
		   			    if(recruitment_result_id!=null&&!"".equals(recruitment_result_id)){
		   			    	tgRecruitmentResult.setId(Long.parseLong(recruitment_result_id));
		   			    }
		   			    
		   			    Page page1=PageUtil.createPage(10, 1, 10);
		   			    List<TgRecruitmentResult>ls=recruitmentResultDao.getTgRecruitResultByType(tgRecruitmentResult,page1);
		   			    if(ls!=null&&ls.size()>0){
		   			    	tgRecruitmentPeople.setUsername(ls.get(0).getName());
		   			    }
		   			    if(recruitment_result_id!=null&&!"".equals(recruitment_result_id)){
		   			    	Page page=PageUtil.createPage(10, 1, 10);
		   			    	tgRecruitmentPeople.setRecruitment_result_id(Long.parseLong(recruitment_result_id));
		   			    	list=recruitmentPeopleDao.getTgRecruitPeopleByType(tgRecruitmentPeople,page);
		   			    }
		   			    if((id==null||"".equals(id))&&list!=null&&list.size()>0){//此人已经添加过了
		   			    	result.setDefaultModel("msg", "2");
		   			    }else{
		   			        if(type!=null&&!"".equals(type)){
		   			        	tgRecruitmentPeople.setType(Integer.parseInt(type));
		   			        }
		   			    	tgRecruitmentPeople.setEmployeeperiod(employeeperiod);
			   			    tgRecruitmentPeople.setProbationperiod(probationperiod);
			   			    tgRecruitmentPeople.setBoccardnumber(boccardnumber);
			   			    tgRecruitmentPeople.setTransactionsituation(transactionsituation);
		   			        if(incomecompanytime!=null&&!"".equals(incomecompanytime)){
		   			    	     SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
								 Date d=sdf.parse(incomecompanytime);
								 tgRecruitmentPeople.setIncomecompanytime(d);
		   			         }
		   			         if(id!=null&&!"".equals(id)){
		   			        	 tgRecruitmentPeople.setId(Long.parseLong(id));
		   			        	 TgRecruitmentPeople tgRecruitmentPeople1= recruitmentPeopleDao.findById(TgRecruitmentPeople.class, Long.parseLong(id));
		   			        	 
		   			        	 recruitmentPeopleDao.update(tgRecruitmentPeople);
		   			         }else{
		   			        	 recruitmentPeopleDao.insert(tgRecruitmentPeople);
		   			         }
		   			         result.setDefaultModel("msg", "1");
		   			    }
	   				}catch (ParseException e) {
						e.printStackTrace();
					}
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_recruitment_people", modelMap);
	   	}
	    /**
	     * 每日预约分析
	     * @param modelMap
	     * @param vo
	     * @param request
	     * @param response
	     * @return
	     * @throws Exception
	     */
	    @RequestMapping(value = "/recruitment_so_list")
	    public ModelAndView daySoList(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                
	                TgRecruitment tgRecruitment=new TgRecruitment();
	                TgUser user=UserUtil.getCookieUser();
	                String dateday=request.getParameter("dateday");
	                List<TgRecruitment>list=new ArrayList<TgRecruitment>();
	                List<RecruitmentRate>list1=new ArrayList<RecruitmentRate>();
	               
	                if(dateday!=null&&!"".equals(dateday)){
	                	dateday=dateDay(dateday);
	                }else{//默认按照今天
	                	Date date=new Date();
	  	                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	  	                dateday=sdf.format(date);
	  	                dateday=dateDay(dateday);
	  	                
	                }
	                if(user.getUsername().equals("system")||user.getUsername().equals("xuhengchen")){//查看所有
	                	list=recruitmentDao.getTgRecruitmentByType3(tgRecruitment);
	                }else{
	                	tgRecruitment.setLogin_name(user.getUsername());
	 	                tgRecruitment.setUsername(user.getNickname());
	                	list.add(tgRecruitment);
	                }
	                if(list!=null&&list.size()>0){
	                	for(int i=0;i<list.size();i++){
	                		RecruitmentRate recruitmentRate=new RecruitmentRate();
	                		list.get(i).setDateday(dateday);
	      	                Integer total=recruitmentDao.getTgCountRecruitmentByType(list.get(i));
	      	                recruitmentRate.setTotal(total);
	      	                list.get(i).setSuccess(1);
	      	                Integer tosuccess=recruitmentDao.getTgCountRecruitmentByType(list.get(i));
	      	                recruitmentRate.setTosuccess(tosuccess);
	      	                String rate="";
	      	                if(total!=0){
	      	                	  Double d= tosuccess/(double)total;
	      	                	  String f=df.format(d*100);
	                    			  rate=f+"%";
	      	                }
	      	                recruitmentRate.setRate(rate);
	      	                List<TgRecruitment>ls=recruitmentDao.getTgRecruitmentByType2(list.get(i));
	      	                String region="";
	      	                TgRecruitment tgRecruit=new TgRecruitment();
	      	                tgRecruit.setDateday(dateday);
	      	                tgRecruit.setLogin_name(list.get(i).getLogin_name());
	      	                if(ls!=null&&ls.size()>0){
	      	                	for(int j=0;j<ls.size();j++){
	      	                		if(ls.get(j).getRegion()!=null&&j<ls.size()-1){
	      	                			tgRecruit.setSuccess(1);
	      	                			tgRecruit.setRegion(ls.get(j).getRegion());
	      	                			Integer count=recruitmentDao.getTgCountRecruitmentByType(tgRecruit);
	      	                			region=region+count+ls.get(j).getRegion()+",";
	      		                	}else{
	      		                		tgRecruit.setSuccess(1);
	      		                		tgRecruit.setRegion(ls.get(j).getRegion());
	      	                			Integer count=recruitmentDao.getTgCountRecruitmentByType(tgRecruit);
	      	                			region=region+count+ls.get(j).getRegion();
	      		                	}
	      	                	}
	      	                }
	      	                recruitmentRate.setName(list.get(i).getUsername());
	      	                recruitmentRate.setRegion(region);
	      	                list1.add(recruitmentRate);
	                	}
	                }
	              
	                result.setDefaultModel("list", list1);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/recruitment_result_day", modelMap);
	    }
	    /**
	     * 今日面试人数统计
	     * @param modelMap
	     * @param vo
	     * @param request
	     * @param response
	     * @return
	     * @throws Exception
	     */
	    @RequestMapping(value = "/recruitment_Interview_list")
	    public ModelAndView recruitment_Interview_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                TgRecruitmentResult tgRecruitmentResult=new TgRecruitmentResult();
	                List<TgRecruitment>list=new ArrayList<TgRecruitment>();
	                List<RecruitmentRate>list1=new ArrayList<RecruitmentRate>();
	                TgRecruitment tgRecruitment=new TgRecruitment();
	                TgUser user=UserUtil.getCookieUser();
	                String dateday=request.getParameter("dateday");
	                if(dateday!=null&&!"".equals(dateday)){
	                	dateday=dateDay(dateday);
	                }else{//默认当日
	                	Date date=new Date();
	  	                SimpleDateFormat sdf=new SimpleDateFormat("YYYY-MM-dd");
	  	                dateday=sdf.format(date);
	  	                dateday=dateDay(dateday);
	                }
	                if(user.getUsername().equals("system")||user.getUsername().equals("xuhengchen")){//查看所有
	                	list=recruitmentDao.getTgRecruitmentByType3(tgRecruitment);
	                }else{
	                	tgRecruitment.setLogin_name(user.getUsername());
	                	 
	 	                tgRecruitment.setUsername(user.getNickname());
	                	list.add(tgRecruitment);
	                }
	                if(list!=null&&list.size()>0){
	                	for(int j=0;j<list.size();j++){
	                		RecruitmentRate recruitmentRate=new RecruitmentRate();
	                		list.get(j).setDateday(dateday);
	                		list.get(j).setSuccess(1);
	    	                tgRecruitmentResult.setDateday(dateday);
	    	                tgRecruitmentResult.setLogin_name(list.get(j).getLogin_name());
	    	                Integer totalYG=recruitmentDao.getTgCountRecruitmentByType1(list.get(j));//今天该到来的学生
	    	                recruitmentRate.setTotalYG(totalYG);
	    	                
	    	                Integer total=recruitmentResultDao.getTgCountRecruitResultByType(tgRecruitmentResult);
	    	                recruitmentRate.setTotal(total);
	    	                String rate="";
	    	                if(totalYG!=null&&totalYG!=0){
	    	                	Double d= total/(double)totalYG;
	    	                	d=d*100;
	    	                	String f=df.format(d);
	    	                	rate=f+"%";
	    	                }
	    	                recruitmentRate.setRate(rate);
	    	                String beizhu="";
	    	                List<TgRecruitmentResult>ls=recruitmentResultDao.getTgRecruitResultByType1(tgRecruitmentResult);
	    	                TgRecruitmentResult tgRecruitResult=new TgRecruitmentResult();
	    	                if(ls!=null&&ls.size()>0){
	    	                	for(int i=0;i<ls.size();i++){
	    	                	    tgRecruitResult.setResult(ls.get(i).getResult());
	    	                	    tgRecruitResult.setLogin_name(list.get(j).getLogin_name());
	    	                	    tgRecruitResult.setDateday(dateday);
	    	                		Integer count =recruitmentResultDao.getTgCountRecruitResultByType(tgRecruitResult);
	    	                		if(i<ls.size()-1){
	    	                			if(ls.get(i).getResult()!=null&&ls.get(i).getResult()==1){
	    		                			beizhu=beizhu+count+"通过"+","; 
	    		                		}	
	    		                		if(ls.get(i).getResult()!=null&&ls.get(i).getResult()==2){
	    		                			beizhu=beizhu+count+"待定"+","; 
	    		                		}	
	    		                		if(ls.get(i).getResult()!=null&&ls.get(i).getResult()==3){
	    		                			beizhu=beizhu+count+"不通过"+",";
	    		                		}	
	    	                		}else{
	    	                			if(ls.get(i).getResult()!=null&&ls.get(i).getResult()==1){
	    		                			beizhu=beizhu+count+"通过";
	    		                		}	
	    		                		if(ls.get(i).getResult()!=null&&ls.get(i).getResult()==2){
	    		                			beizhu=beizhu+count+"待定";
	    		                		}	
	    		                		if(ls.get(i).getResult()!=null&&ls.get(i).getResult()==3){
	    		                			beizhu=beizhu+count+"不通过";
	    		                		}	
	    	                		}
	    	                		
	    	                	}
	    	                }
	    	                recruitmentRate.setBeizhu(beizhu);
	    	                recruitmentRate.setName(list.get(j).getUsername());
	    	                list1.add(recruitmentRate);
	                	}
	                }
	                
	                result.setDefaultModel("dateday", dateday);
	                result.setDefaultModel("list", list1);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/recruitment_result_interview", modelMap);
	    }
	    /**
	     * 人员分析表
	     * @param modelMap
	     * @param vo
	     * @param request
	     * @param response
	     * @return
	     * @throws Exception
	     */
	    @RequestMapping(value = "/recruitment_total_list")
	    public ModelAndView recruitment_total_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                TgRecruitmentPeople tgRecruitmentPeople=new TgRecruitmentPeople();//查出学员总数，已邀请人分组
	                TgUser user=UserUtil.getCookieUser();
	                if(!user.getUsername().equals("system")&&!user.getUsername().equals("xuhengchen")){
	                	tgRecruitmentPeople.setUsername(user.getUsername());
	                }
	                
	                List<TgRecruitmentPeople>list=recruitmentPeopleDao.getTgRecruitPeopleByType2(tgRecruitmentPeople);
	             
	                if(list!=null&&list.size()>0){
	                	for(int i=0;i<list.size();i++){
	                		if(list.get(i).getUsername()!=null){
	                			List<TgRecruitmentPeople>li=recruitmentPeopleDao.getTgRecruitPeopleByType3(list.get(i));
	                			if(li!=null&&li.size()>0){
	                			    TgRecruitmentPeople tgRecruitPeople=new TgRecruitmentPeople();
	                				tgRecruitPeople.setUsername(list.get(i).getUsername());
                					int total=recruitmentPeopleDao.getTgCountRecruitPeopleByType(tgRecruitPeople);
                				    list.get(i).setCount(total);
	                				for(int j=0;j<li.size();j++){
	                					tgRecruitPeople.setType(li.get(j).getType());
	                					Integer count=recruitmentPeopleDao.getTgCountRecruitPeopleByType(tgRecruitPeople);
	                					if(li.get(j).getType()!=null&&li.get(j).getType()==1){//正在培训人数
	                						list.get(i).setCount1(count);
	                					}
	                					if(li.get(j).getType()!=null&&li.get(j).getType()==2){//已入职人数
	                						list.get(i).setCount2(count);
	                					}
	                					if(li.get(j).getType()!=null&&li.get(j).getType()==3){//已通知报道却没有来的人数
	                						list.get(i).setCount3(count);
	                					}
	                					if(li.get(j).getType()!=null&&li.get(j).getType()==4){//培训期间离开的人数
	                						list.get(i).setCount4(count);
	                					}
	                					if(li.get(j).getType()!=null&&li.get(j).getType()==5){//入职后离开的人数
	                						list.get(i).setCount5(count);
	                					}
	                					if(li.get(j).getType()!=null&&li.get(j).getType()==6){//已确定但未到报到时间的人
	                						list.get(i).setCount6(count);
	                					}
	                				}
	                			}
	                		}
	                		if(list.get(i).getCount()!=null&&list.get(i).getCount()!=0&&list.get(i).getCount2()!=null){//入职率
	                			Double d=(list.get(i).getCount2()/(double)list.get(i).getCount());
	                			String f=df.format(d*100);
	                			String rate=f+"%";
	                			list.get(i).setRate(rate);
	                		}
	                		if(list.get(i).getCount()!=null&&list.get(i).getCount()!=0&&list.get(i).getCount4()!=null){//培训期间离职率
	                			Double d= (list.get(i).getCount4()/(double)list.get(i).getCount());
	                			String f=df.format(d*100);
	                			String rate=f+"%";
	                			list.get(i).setTrailRate(rate);
	                		}
	                		if(list.get(i).getCount()!=null&&list.get(i).getCount()!=0&&list.get(i).getCount3()!=null){//放弃报道率
	                			Double d= (list.get(i).getCount3()/(double)list.get(i).getCount());
	                			String f=df.format(d*100);
	                			String rate=f+"%";
	                			list.get(i).setGiveUpRate(rate);
	                		}
	                	}
	                }
	                result.setDefaultModel("list", list);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/recruitment_people_list1", modelMap);
	    }
	    @RequestMapping(value = "/satis_survey_list")
	    public ModelAndView satisfaction_survey_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                int currPage=1;
	                if(vo.getCurrPage()!=null){
	                	currPage=vo.getCurrPage();
	                }
	                List<TgSatisSurvey>list=new ArrayList<TgSatisSurvey>();
	                TgUser user=UserUtil.getCookieUser();
	                if(!user.getUsername().equals("jingsi")){
	                	TgSatisSurvey satisSurvey=new TgSatisSurvey();
	  	                int total=satisSurveyDao.getCountSatisSurveyByType(satisSurvey);
	  	                Page page=PageUtil.createPage(10, currPage, total);
	  	                list=satisSurveyDao.getSatisSurveyByType(satisSurvey, page);
	  	                result.setDefaultModel("page", page);
	  	                result.setDefaultModel("list", list);
	                }else{
	                    Page page=PageUtil.createPage(10, 1, 0);
	                	result.setDefaultModel("page", page);
		  	            result.setDefaultModel("list", list);
	                }
	                return result;
	            }
	        });
	        return new ModelAndView("work/satis_survey_list", modelMap);
	    }
	    @RequestMapping(value = "/add_satis_survey")
	    public ModelAndView add_satisfaction_survey(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                return result;
	            }
	        });
	        return new ModelAndView("work/add_satis_survey", modelMap);
	    }
	    @RequestMapping(value = "/addSatisSurvey")
	   	public ModelAndView addSatisSurvey(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				TgSatisSurvey satisSurvey=new TgSatisSurvey();
	   				String satis_degree1 = request.getParameter("satis_degree1");
	   			    String satis_degree_evaluate1=request.getParameter("satis_degree_evaluate1");
	   			    String satis_degree2 = request.getParameter("satis_degree2");
	   			    String satis_degree_evaluate2=request.getParameter("satis_degree_evaluate2");
	   			    String satis_degree3 = request.getParameter("satis_degree3");
	   			    String satis_degree_evaluate3=request.getParameter("satis_degree_evaluate3");
	   			    String satis_degree4 = request.getParameter("satis_degree4");
	   			    String satis_degree_evaluate4=request.getParameter("satis_degree_evaluate4");
	   			    String satis_degree_evaluate5=request.getParameter("satis_degree_evaluate5");
	   			    if(satis_degree1!=null&&!"".equals(satis_degree1)){
	   			    	satisSurvey.setSatis_degree1(Integer.parseInt(satis_degree1));
	   			    }
	   			    if(satis_degree2!=null&&!"".equals(satis_degree2)){
	   			    	satisSurvey.setSatis_degree2(Integer.parseInt(satis_degree2));
	   			    }
	   			    if(satis_degree3!=null&&!"".equals(satis_degree3)){
   			    	    satisSurvey.setSatis_degree3(Integer.parseInt(satis_degree3));
   			        }
	   			    if(satis_degree4!=null&&!"".equals(satis_degree4)){
   			    	    satisSurvey.setSatis_degree4(Integer.parseInt(satis_degree4));
   			        }
	   			    satisSurvey.setSatis_degree_evaluate1(satis_degree_evaluate1);
	   		    	satisSurvey.setSatis_degree_evaluate2(satis_degree_evaluate2);
	   			    satisSurvey.setSatis_degree_evaluate3(satis_degree_evaluate3);
	   			    satisSurvey.setSatis_degree_evaluate4(satis_degree_evaluate4);
	   			    satisSurvey.setSatis_degree_evaluate5(satis_degree_evaluate5);
	   			    satisSurveyDao.insert(satisSurvey);
	   			    result.setDefaultModel("msg", 1);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/add_satis_survey", modelMap);
	   	}
	    @RequestMapping(value = "/download_survey")
	   	public ModelAndView download_survey(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				TgSatisSurvey satisSurvey=new TgSatisSurvey();
	   				List<TgSatisSurvey>list=satisSurveyDao.getSatisSurveyByType1(satisSurvey);
	                String name= WriterExcel.writeSurvey(list);
	                result.setDefaultModel("name", name);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("", modelMap);
	   	}
	    @RequestMapping(value = "/quit_list")
	    public ModelAndView quit_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                TgQuit quit=new TgQuit();//查出学员总数，已邀请人分组
	                String week=request.getParameter("week");
	                String math=request.getParameter("math");
	                String name=request.getParameter("name");
	                if(week!=null&&!"".equals(week)){
	                	List<String>weekList=DateUtil.printWeekdays(week);
	                	if(weekList!=null&&weekList.size()>0){
	                		quit.setStart(weekList.get(0));
	                		quit.setEnd(weekList.get(weekList.size()-1));
	                	}
	                }
	                if(math!=null&&!"".equals(math)){
	                	try {
							quit.setStart(math+"-01");
							quit.setEnd(sdf.format(DateUtil.getMonthLast(math)));
						} catch (Exception e) { 
							e.printStackTrace();
						}
	                	quit.setMath(math);
	                }
	                if(name!=null&&!"".equals(name)){
	                	quit.setUsername(name);
	                }
	                //TgUser user=UserUtil.getCookieUser();
	               //quit.setFill_in_name(user.getUsername());
	                Integer curr=1;
	                if(vo.getCurrPage()!=null){
	                	curr=vo.getCurrPage();
	                }
	                int total=quitDao.getCountQuitByType(quit);
	                Page page=PageUtil.createPage(10, curr, total);
	                List<TgQuit>list=quitDao.getQuitByType(quit, page);
	                result.setDefaultModel("list", list);
	                result.setDefaultModel("page", page);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/quit_list", modelMap);
	    }
	    
	    
	    
	    @RequestMapping(value = "/add_quit")
	    public ModelAndView add_quit(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                String id=request.getParameter("id");
	                if(id!=null&&!"".equals(id)){
	                	 TgQuit quit=quitDao.findById(TgQuit.class, Long.parseLong(id));
	                	 result.setDefaultModel("quit", quit);
	                }
	                List<TgUserinfo>ulist=userinfoDao.getUserInfoByUserInfo(new TgUserinfo());
	              
	                result.setDefaultModel("ulist", ulist);
	                List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);//查询中心
				    result.setDefaultModel("office_List", office_List);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/add_quit", modelMap);
	    }
	    
	    //根据中心筛选老师
	    @RequestMapping(value = "/getTeacherByCenter")
		public ModelAndView getTeacherByCenter(ModelMap modelMap, final BaseVo vo,
				final HttpServletRequest request, HttpServletResponse response)
						throws BaseException {
			modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
				public Result process() {
					Result result = new ResultSupport(true);
					String center = request.getParameter("center");
					if(center!=null && !"".equals(center)){
						
						TgUserinfo tguser = new TgUserinfo();
						tguser.setRegions(center);
						List<TgUserinfo>  ulist = userinfoDao.getUserInfoByUserInfo(tguser);
						
						result.setDefaultModel("ulist", ulist);
					}
					return result;
				}
			});
			return new ModelAndView("", modelMap);
		}
	    
	    
	    
	    
	    
	    @RequestMapping(value = "/addQuit")
	   	public ModelAndView addQuit(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				try {
	   					TgQuit quit=new TgQuit();
		   				String id=request.getParameter("id");
		   				String login_name=request.getParameter("login_name");
		   				String username=request.getParameter("username");
		   				String post=request.getParameter("post");
		   				String center=request.getParameter("center");
		   				String good=request.getParameter("good");
		   				String reason=request.getParameter("reason");
		   				String paid_in_accordance=request.getParameter("paid_in_accordance");
		   				String type=request.getParameter("type");
		   				String phone=request.getParameter("phone");
		   				String induction_time=request.getParameter("induction_time");
		   				String departure_time=request.getParameter("departure_time");
		   				String social_security=request.getParameter("social_security");
		   				String work_clothes=request.getParameter("work_clothes");
		   				String beizhu=request.getParameter("beizhu");
		   				String sex=request.getParameter("sex");
		   				String email=request.getParameter("email");
		   				TgUser use=UserUtil.getCookieUser();
		   				TgUser user=new TgUser();
		   				if(username!=null&&!"".equals(username)){
		   					quit.setUsername(username);
		   				}else if(login_name!=null&&!"".equals(login_name)){
		   					user.setUsername(login_name);
		   					user=userDao.getUserInfoByType(user);
		   					quit.setUsername(user.getNickname());
		   					quit.setLogin_name(user.getUsername());
		   				}
		   				if(sex!=null&&!"".equals(sex)){
		   					quit.setSex(Integer.parseInt(sex));
		   				}
		   				if(departure_time!=null&&!"".equals(departure_time)){
		   					quit.setDeparture_time(sdf.parse(departure_time));
		   				}
		   				if(induction_time!=null&&!"".equals(induction_time)){
						    quit.setInduction_time(sdf.parse(induction_time));
		   				}
		   				if(social_security!=null&&!"".equals(social_security)){
		   					quit.setSocial_security(Integer.parseInt(social_security));
		   				}
		   				
		   				if(paid_in_accordance!=null&&!"".equals(paid_in_accordance)){
		   					quit.setPaid_in_accordance(Integer.parseInt(paid_in_accordance));
		   					
		   				}
		   				if(work_clothes!=null&&!"".equals(work_clothes)){
		   					quit.setWork_clothes(Integer.parseInt(work_clothes));
		   				}
		   				if(type!=null&&!"".equals(type)){
		   					quit.setType(Integer.parseInt(type));
		   				}
		   				quit.setEmail(email);
		   				quit.setGood(good);
		   				quit.setFill_in_name(use.getUsername());
			   		    quit.setFill_in_nickname(use.getNickname());
		   				quit.setBeizhu(beizhu);
		   				quit.setCenter(center);
		   				quit.setPhone(phone);
		   				quit.setPost(post);
		   				quit.setReason(reason);
		   				quit.setCreate_time(new Date());
		   				if(id!=null&&!"".equals(id)){
		   					quit.setId(Long.parseLong(id));
		   					TgQuit quit1=quitDao.findById(TgQuit.class, Long.parseLong(id));
		   					if(sex==null||"".equals(sex)){
			   					quit.setSex(quit1.getSex());
			   				}
		   					if(social_security==null||"".equals(social_security)){
			   					quit.setSocial_security(quit1.getSocial_security());
			   				}
			   				
			   				if(paid_in_accordance==null||"".equals(paid_in_accordance)){
			   					quit.setPaid_in_accordance(quit1.getPaid_in_accordance());
			   					
			   				}
			   				if(type==null||"".equals(type)){
			   					quit.setType(quit1.getType());
			   				}
			   				if(work_clothes==null||"".equals(work_clothes)){
			   					quit.setWork_clothes(quit1.getWork_clothes());
			   				}
			   				quit.setFill_in_name(quit1.getFill_in_name());
			   				quit.setFill_in_nickname(quit1.getFill_in_nickname());
		   					quitDao.update(quit);
		   				}else{
		   					quitDao.insert(quit);
		   				}
		   			    result.setDefaultModel("msg", 1);
	   				} catch (ParseException e) {
						e.printStackTrace();
					}
		   			return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_good_provide.ftl", modelMap);
	   	}
	    @RequestMapping(value = "/delete_quit")
	    public ModelAndView delete_quit(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                TgQuit quit=new TgQuit();//查出学员总数，已邀请人分组
	                String id=request.getParameter("id");
	                if(id!=null&&!"".equals(id)){
	                	quit.setId(Long.parseLong(id));
	                	quitDao.delete(quit);
	                }
	                Integer curr=1;
	                if(vo.getCurrPage()!=null){
	                	curr=vo.getCurrPage();
	                }
	                int total=quitDao.getCountQuitByType(quit);
	                Page page=PageUtil.createPage(10, curr, total);
	                List<TgQuit>list=quitDao.getQuitByType(quit, page);
	                result.setDefaultModel("list", list);
	                result.setDefaultModel("page", page);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/quit_list", modelMap);
	    }
	    @RequestMapping(value = "/good_provide_list")
	    public ModelAndView good_provide_list(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	             
	                String center=request.getParameter("center");
	                String username=request.getParameter("username");
	                String zhiw=request.getParameter("zhiw");
	                TgGoodProvide goodProvide=new TgGoodProvide();
	                if(center!=null&&!"".equals(center)){
	                	goodProvide.setCenter(center);
	                }
	                if(username!=null&&!"".equals(username)){
	                	goodProvide.setUsername(username);
	                }
	                if(zhiw!=null&&!"".equals(zhiw)){
	                	goodProvide.setDepartment(zhiw);
	                	
	                }
	                int curr=1;
	                if(vo.getCurrPage()!=null){
	                	curr=vo.getCurrPage();
	                }
	                TgDepartment department = new TgDepartment();
	   				department.setParent("0");
					List<TgDepartment> depList = tgDepartmentDao.findByExample(department);
	                result.setDefaultModel("depList",depList);
	                
	                Integer total=goodProvideDao.getCountGoodProvideByType(goodProvide);
	                Page page=PageUtil.createPage(10, curr, total);
	                List<TgGoodProvide>list=goodProvideDao.getGoodProvideByType(goodProvide, page);
	                result.setDefaultModel("page", page);
	                result.setDefaultModel("list", list);
	                List<TgUserinfo>ulist=userinfoDao.getUserInfoByUserInfo(new TgUserinfo());
	                result.setDefaultModel("ulist", ulist);
	                List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);//查询中心
				    result.setDefaultModel("office_List", office_List);
				    result.setDefaultModel("center", center);
				    result.setDefaultModel("zhiw", zhiw);
				    result.setDefaultModel("username",username);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/good_provide_list", modelMap);
	    }
	    //下载物品发放统计
	    @RequestMapping(value = "/xzRecruit")
	    public ModelAndView xzRecruit(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	             
	                String center=request.getParameter("center");
	                String username=request.getParameter("username");
	                String zhiw=request.getParameter("zhiw");
	                TgGoodProvide goodProvide=new TgGoodProvide();
	                if(center!=null&&!"".equals(center)){
	                	goodProvide.setCenter(center);
	                }
	                if(username!=null&&!"".equals(username)){
	                	goodProvide.setUsername(username);
	                }
	                if(zhiw!=null&&!"".equals(zhiw)){
	                	goodProvide.setDepartment(zhiw);
	                	
	                }
	                int curr=1;
	                if(vo.getCurrPage()!=null){
	                	curr=vo.getCurrPage();
	                }
	                TgDepartment department = new TgDepartment();
	   				department.setParent("0");
					List<TgDepartment> depList = tgDepartmentDao.findByExample(department);
	                result.setDefaultModel("depList",depList);
	                
	                Integer total=goodProvideDao.getCountGoodProvideByType(goodProvide);
	                Page page=PageUtil.createPage(10, curr, total);
	                List<TgGoodProvide>list=goodProvideDao.getGoodProvideByType(goodProvide, page);
	                result.setDefaultModel("page", page);
	                result.setDefaultModel("list", list);
	                List<TgUserinfo>ulist=userinfoDao.getUserInfoByUserInfo(new TgUserinfo());
	                result.setDefaultModel("ulist", ulist);
	                List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);//查询中心
				    result.setDefaultModel("office_List", office_List);
				    
				    String name = WriterExcel.writeExcelWup(list, center);
					result.setDefaultModel("name", name);
					
	                return result;
	            }
	        });
	        return new ModelAndView("", modelMap);
	    }
	    @RequestMapping(value = "/add_good_provide")
	    public ModelAndView add_good_provide(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                String id=request.getParameter("id");
	                if(id!=null&&!"".equals(id)){
	                	TgGoodProvide goodProvide=goodProvideDao.findById(TgGoodProvide.class, Long.parseLong(id));
	                	 result.setDefaultModel("goodProvide", goodProvide);
	                }
	                List<TgUserinfo>ulist=userinfoDao.getUserInfoByUserInfo(new TgUserinfo());
	                result.setDefaultModel("ulist", ulist);
	                List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);//查询中心
				    result.setDefaultModel("office_List", office_List);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/add_good_provide", modelMap);
	    }
	    @RequestMapping(value = "/addGoodProvide")
	   	public ModelAndView addGoodProvide(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				String id=request.getParameter("id");
	   				String login_name=request.getParameter("login_name");
	   				String post=request.getParameter("post");
	   				String center=request.getParameter("center");
	   				String good=request.getParameter("good");
	   				String department=request.getParameter("department");
	   				String date_of_entry=request.getParameter("date_of_entry");
	   				String date_of_regist=request.getParameter("date_of_regist");
	   				String beizhu=request.getParameter("beizhu");
	   				TgUser user=UserUtil.getCookieUser();
	   				TgUserinfo userinfo=new TgUserinfo();
	   				TgGoodProvide goodProvide=new TgGoodProvide();
	   				if(login_name!=null&&!"".equals(login_name)){
	   					userinfo.setUsername(login_name);
	   					List<TgUserinfo>lst=userinfoDao.getUserInfoByUserInfo(userinfo);
	   					if(lst!=null&&lst.size()>0){
	   						userinfo=lst.get(0);
	   					}
	   				}
	   				if(post==null||"".equals(post)){
	   					goodProvide.setPost(userinfo.getJob());
	   				}else{
	   					goodProvide.setPost(post);
	   				}
	   				if(department==null||"".equals(department)){
	   					goodProvide.setDepartment(userinfo.getDepartments());
	   				}else{
	   					goodProvide.setDepartment(department);
	   				}
	   				goodProvide.setCenter(center);
	   				goodProvide.setBeizhu(beizhu);
	   				goodProvide.setHandle_person(user.getNickname());
	   				goodProvide.setLogin_name(login_name);
	   				goodProvide.setUsername(userinfo.getNickname());
	   				goodProvide.setGood(good);
	   				goodProvide.setDate_of_entry(date_of_entry);
	   				
	   				goodProvide.setDate_of_regist(date_of_regist);
	   				if(id!=null&&!"".equals(id)){
	   					goodProvide.setId(Long.parseLong(id));
	   					goodProvideDao.update(goodProvide);
	   				}else{
	   					goodProvide.setCreate_time(new Date());
	   					goodProvideDao.insert(goodProvide);
	   				}
	   				result.setDefaultModel("msg", 1);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("work/recruitment/add_good_provide", modelMap);
	   	}
	    //下载员工离职表
	    @RequestMapping(value = "/download_quit")
	   	public ModelAndView download_quit(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				TgQuit quit=new TgQuit();
	   			    String week=request.getParameter("week");
	                String math=request.getParameter("math");
	                if(week!=null&&!"".equals(week)){
	                	List<String>weekList=DateUtil.printWeekdays(week);
	                	if(weekList!=null&&weekList.size()>0){
	                		quit.setStart(weekList.get(0));
	                		quit.setEnd(weekList.get(weekList.size()-1));
	                	}
	                }
	                if(math!=null&&!"".equals(math)){
	                	quit.setMath(math);
	                }
	                List<TgQuit>list=quitDao.getQuitByType1(quit);
	                String name=WriterExcel.writeQuit(list);
	   				result.setDefaultModel("name", name);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("", modelMap);
	   	}
	    @RequestMapping(value = "/storage_list")
	   	public ModelAndView storage_list(ModelMap modelMap, final BaseVo vo,
	   			final HttpServletRequest request, final HttpServletResponse response)
	   			throws Exception {
	    	modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
	   			public Result process() {
	   				Result result = new ResultSupport(true);
	   				 
	   			    String center=request.getParameter("center");
	                String number=request.getParameter("number");
	                TgStorage storage=new  TgStorage();
	                if(center!=null&&!"".equals(center)){
	                	storage.setCenter(center);
	                }
	                if(number!=null&&!"".equals(number)){
	                	storage.setNumber(number);
	                }
	                int curr=1;
	                if(vo.getCurrPage()!=null){
	                	curr=vo.getCurrPage();
	                }
	                Integer total=storageDao.getCountStorageByType(storage);
	                Page page=PageUtil.createPage(10, curr, total);
	                List<TgStorage>list=storageDao.getStorageByType(storage, page);
	   				return result;
	   			}
	   		});
	   		return new ModelAndView("", modelMap);
	   	}
	
	    
	    @RequestMapping(value = "/ck_quit")
	    public ModelAndView ck_quit(ModelMap modelMap, final BaseVo vo,
	            final HttpServletRequest request, final HttpServletResponse response)
	            throws Exception {
	        modelMap = WebExecutor.execute(logger, vo, new Biz() {
	            public Result process() {
	                Result result = new ResultSupport(true);
	                String id=request.getParameter("id");
	                
	                TgQuit quit = new TgQuit();
	               
	                YgZl ygzl = new YgZl();
	                //员工离职  查到员工名字
	                if(id!=null&&!"".equals(id)){
	                	 quit=quitDao.findById(TgQuit.class, Long.parseLong(id));

	                	 ygzl.setTglist(quit);
	                }
	                //招聘反馈   名字带入查询
	   				if(quit!=null){
	   				    TgGoodProvide good = new TgGoodProvide();
	   					TgRecruitment tgre = new TgRecruitment();
	   					tgre.setName(quit.getUsername());
	   					good.setUsername(quit.getUsername());
	   					good.setLogin_name(quit.getLogin_name());
	   					List<TgRecruitment>	recruitment= recruitmentDao.getTgRecruitment(tgre);
	   					
	   					if(recruitment!=null && recruitment.size()>0){
	   						ygzl.setTgreclist(recruitment.get(0));
							}
	   					
	   					//物品发放
	   					List<TgGoodProvide> goodlist=goodProvideDao.getGoodProvide(good);
	   					if(goodlist!=null && goodlist.size()>0){
   							ygzl.setTgprovlist(goodlist.get(0));
							}
	   					
	   					ygzl.setCenter(quit.getCenter());
	   					ygzl.setZyname(quit.getUsername());
	   					//面试信息		
	   					if(recruitment!=null && recruitment.size()>0){
	   						TgRecruitment recment = recruitment.get(0);
	   						TgRecruitmentResult tgrecresult = new TgRecruitmentResult();
	   						tgrecresult.setRecruitment_id(recment.getId());
	   						List<TgRecruitmentResult> tgRecruitmentResult = recruitmentResultDao.getTgRecruitResult(tgrecresult);
	   						
	   						if(tgRecruitmentResult!=null && tgRecruitmentResult.size()>0){
	   							ygzl.setTgrecreslist(tgRecruitmentResult.get(0));
   							}else{
   								ygzl.setTgrecreslist(null);
   							}
	   						//员工情况表
	   						if(tgRecruitmentResult !=null && tgRecruitmentResult.size()>0){
	   							TgRecruitmentResult recres = tgRecruitmentResult.get(0);
	   							TgRecruitmentPeople recpeo = new TgRecruitmentPeople();
	   							recpeo.setRecruitment_result_id(recres.getId());
	   							
	   							Integer currPage = vo.getCurrPage() == null ? 1 : vo.getCurrPage();
	   			                Integer total=recruitmentPeopleDao.getTgCountRecruitPeopleByType(recpeo);
	   			                Page page=PageUtil.createPage(10, currPage, total);
	   							List<TgRecruitmentPeople> Peoplelist=recruitmentPeopleDao.getTgRecruitPeopleByType(recpeo, page);
	   							if(Peoplelist!=null && Peoplelist.size()>0){
	   								ygzl.setTgrecpeolist(Peoplelist.get(0));
	   							}else{
	   								ygzl.setTgrecpeolist(null);
	   							}
	   						}else{
	   							ygzl.setTgrecpeolist(null);
	   						}
	   					}else{
	   						ygzl.setTgrecpeolist(null);
	   						ygzl.setTgrecreslist(null);
	   					}
	   				}else{
	   					ygzl.setTgreclist(null);
	   					ygzl.setTgprovlist(null);
	   					ygzl.setTgrecpeolist(null);
   						ygzl.setTgrecreslist(null);
	   				}
	   				result.setDefaultModel("ygzl",ygzl);
	                List<TgOffice> office_List = tgOfficeDao.findAll(TgOffice.class);//查询中心
				    result.setDefaultModel("office_List", office_List);
	                return result;
	            }
	        });
	        return new ModelAndView("work/recruitment/ck_quit", modelMap);
	    }  
	    
	    
	    public String dateDay(String dateday){
	    	if(dateday!=null&&!"".equals(dateday)){
               	String[] t=dateday.split("-");
               	dateday=t[0]+t[1]+t[2];
               	
            }
	    	return dateday;
	    }
	    public String dateMoth(String datemoth){
	    	if(datemoth!=null&&!"".equals(datemoth)){
	    		String []t=datemoth.split("-");
				datemoth=t[0]+t[1];
	    	}
			return datemoth;
	    }
}
